_init: function() {
this.parent(_("APPLICATIONS"));
-
- this.async = true;
this._appSys = Shell.AppSystem.get_default();
},
- getResultMetasAsync: function(apps, callback) {
+ getResultMetas: function(apps, callback) {
let metas = [];
for (let i = 0; i < apps.length; i++) {
let app = apps[i];
callback(metas);
},
- getInitialResultSetAsync: function(terms) {
+ getInitialResultSet: function(terms) {
this.searchSystem.pushResults(this, this._appSys.initial_search(terms));
},
- getSubsearchResultSetAsync: function(previousResults, terms) {
+ getSubsearchResultSet: function(previousResults, terms) {
this.searchSystem.pushResults(this, this._appSys.subsearch(previousResults, terms));
},
_init: function() {
this.parent(_("SETTINGS"));
- this.async = true;
this._appSys = Shell.AppSystem.get_default();
this._gnomecc = this._appSys.lookup_app('gnome-control-center.desktop');
},
- getResultMetasAsync: function(prefs, callback) {
+ getResultMetas: function(prefs, callback) {
let metas = [];
for (let i = 0; i < prefs.length; i++) {
let pref = prefs[i];
callback(metas);
},
- getInitialResultSetAsync: function(terms) {
+ getInitialResultSet: function(terms) {
this.searchSystem.pushResults(this, this._appSys.search_settings(terms));
},
- getSubsearchResultSetAsync: function(previousResults, terms) {
+ getSubsearchResultSet: function(previousResults, terms) {
this.searchSystem.pushResults(this, this._appSys.search_settings(terms));
},
_init: function() {
this.parent(_("CONTACTS"));
- this.async = true;
this._contactSys = Shell.ContactSystem.get_default();
},
- getResultMetasAsync: function(ids, callback) {
+ getResultMetas: function(ids, callback) {
let metas = [];
for (let i = 0; i < ids.length; i++) {
let contact = new Contact(ids[i]);
callback(metas);
},
- getInitialResultSetAsync: function(terms) {
+ getInitialResultSet: function(terms) {
this.searchSystem.pushResults(this, this._contactSys.initial_search(terms));
},
- getSubsearchResultSetAsync: function(previousResults, terms) {
+ getSubsearchResultSet: function(previousResults, terms) {
this.searchSystem.pushResults(this, this._contactSys.subsearch(previousResults, terms));
},
_init: function() {
this.parent(_("PLACES & DEVICES"));
- this.async = true;
this.placesManager = new PlacesManager();
},
- getResultMetasAsync: function(resultIds, callback) {
+ getResultMetas: function(resultIds, callback) {
let metas = [];
for (let i = 0; i < resultIds.length; i++) {
let placeInfo = this.placesManager.lookupPlaceById(resultIds[i]);
this.searchSystem.pushResults(this, prefixResults.concat(substringResults));
},
- getInitialResultSetAsync: function(terms) {
+ getInitialResultSet: function(terms) {
let places = this.placesManager.getAllPlaces();
this._searchPlaces(places, terms);
},
- getSubsearchResultSetAsync: function(previousResults, terms) {
+ getSubsearchResultSet: function(previousResults, terms) {
let places = previousResults.map(Lang.bind(this, function(id) {
return this.placesManager.lookupPlaceById(id);
}));
dbusName, dbusPath);
this.parent(title.toUpperCase());
- this.async = true;
this._cancellable = new Gio.Cancellable();
},
this.searchSystem.pushResults(this, results[0]);
},
- getInitialResultSetAsync: function(terms) {
+ getInitialResultSet: function(terms) {
this._cancellable.cancel();
this._cancellable.reset();
try {
}
},
- getSubsearchResultSetAsync: function(previousResults, newTerms) {
+ getSubsearchResultSet: function(previousResults, newTerms) {
this._cancellable.cancel();
this._cancellable.reset();
try {
callback(resultMetas);
},
- getResultMetasAsync: function(ids, callback) {
+ getResultMetas: function(ids, callback) {
this._cancellable.cancel();
this._cancellable.reset();
try {
* Subclass this object to add a new result type
* to the search system, then call registerProvider()
* in SearchSystem with an instance.
- * By default, search is synchronous and uses the
+ * Search is asynchronous and uses the
* getInitialResultSet()/getSubsearchResultSet() methods.
- * For asynchronous search, set the async property to true
- * and implement getInitialResultSetAsync()/getSubsearchResultSetAsync()
- * instead.
*/
const SearchProvider = new Lang.Class({
Name: 'SearchProvider',
_init: function(title) {
this.title = title;
this.searchSystem = null;
- this.async = false;
},
/**
* therefore a single term of length one or two), or when
* a new term is added.
*
- * Should return an array of result identifier strings representing
+ * Should "return" an array of result identifier strings representing
* items which match the given search terms. This
* is expected to be a substring match on the metadata for a given
* item. Ordering of returned results is up to the discretion of the provider,
* description) before single matches
* * Put items which match on a prefix before non-prefix substring matches
*
+ * We say "return" above, but in order to make the query asynchronous, use
+ * this.searchSystem.pushResults();. The return value should be ignored.
+ *
* This function should be fast; do not perform unindexed full-text searches
* or network queries.
*/
throw new Error('Not implemented');
},
- /**
- * getInitialResultSetAsync:
- * @terms: Array of search terms, treated as logical AND
- *
- * Like getInitialResultSet(), but the method should return immediately
- * without a return value - use SearchSystem.pushResults() when the
- * corresponding results are ready.
- */
- getInitialResultSetAsync: function(terms) {
- throw new Error('Not implemented');
- },
-
/**
* getSubsearchResultSet:
* @previousResults: Array of item identifiers
*
* This allows search providers to only search through the previous
* result set, rather than possibly performing a full re-query.
- */
- getSubsearchResultSet: function(previousResults, newTerms) {
- throw new Error('Not implemented');
- },
-
- /**
- * getSubsearchResultSetAsync:
- * @previousResults: Array of item identifiers
- * @newTerms: Updated search terms
*
- * Like getSubsearchResultSet(), but the method should return immediately
- * without a return value - use SearchSystem.pushResults() when the
- * corresponding results are ready.
+ * Similar to getInitialResultSet, the return value for this will
+ * be ignored; use this.searchSystem.pushResults();.
*/
- getSubsearchResultSetAsync: function(previousResults, newTerms) {
+ getSubsearchResultSet: function(previousResults, newTerms) {
throw new Error('Not implemented');
},
* getResultMetas:
* @ids: Result identifier strings
*
- * Return an array of objects with 'id', 'name', (both strings) and
+ * Call callback with array of objects with 'id', 'name', (both strings) and
* 'createIcon' (function(size) returning a Clutter.Texture) properties
* with the same number of members as @ids
*/
- getResultMetas: function(ids) {
- throw new Error('Not implemented');
- },
-
- /**
- * getResultMetasAsync:
- * @ids: Result identifier strings
- * @callback: callback to pass the results to when ready
- *
- * Like getResultMetas(), but the method should return immediately
- * without a return value - pass the results to the provided @callback
- * when ready.
- */
- getResultMetasAsync: function(ids, callback) {
+ getResultMetas: function(ids, callback) {
throw new Error('Not implemented');
},
for (let i = 0; i < this._providers.length; i++) {
let [provider, previousResults] = previousResultsArr[i];
try {
- if (provider.async) {
- results.push([provider, []]);
- provider.getSubsearchResultSetAsync(previousResults, terms);
- } else {
- let providerResults = provider.getSubsearchResultSet(previousResults, terms);
- results.push([provider, providerResults]);
- }
+ results.push([provider, []]);
+ provider.getSubsearchResultSet(previousResults, terms);
} catch (error) {
global.log ('A ' + error.name + ' has occured in ' + provider.title + ': ' + error.message);
}
for (let i = 0; i < this._providers.length; i++) {
let provider = this._providers[i];
try {
- if (provider.async) {
- results.push([provider, []]);
- provider.getInitialResultSetAsync(terms);
- } else {
- let providerResults = provider.getInitialResultSet(terms);
- results.push([provider, providerResults]);
- }
+ results.push([provider, []]);
+ provider.getInitialResultSet(terms);
} catch (error) {
global.log ('A ' + error.name + ' has occured in ' + provider.title + ': ' + error.message);
}
if (results.length == 0)
return;
- if (provider.async) {
- provider.getResultMetasAsync(results,
- Lang.bind(this, this.renderResults));
- } else {
- let metas = provider.getResultMetas(results);
- this.renderResults(metas);
- }
+ provider.getResultMetas(results, Lang.bind(this, this.renderResults));
}));
}));
this._notDisplayedResult = [];
meta.resultDisplay.setResults(providerResults, terms);
let results = meta.resultDisplay.getResultsForDisplay();
- if (provider.async) {
- provider.getResultMetasAsync(results, Lang.bind(this,
- function(metas) {
- this._clearDisplayForProvider(provider);
- meta.actor.show();
-
- // Hinding drops the key focus if we have it
- let focus = global.stage.get_key_focus();
- this._content.hide();
-
- meta.resultDisplay.renderResults(metas);
- this._maybeSetInitialSelection();
-
- this._content.show();
- if (this._content.contains(focus))
- global.stage.set_key_focus(focus);
- }));
- } else {
- let metas = provider.getResultMetas(results);
+ provider.getResultMetas(results, Lang.bind(this, function(metas) {
this._clearDisplayForProvider(provider);
meta.actor.show();
+
+ // Hinding drops the key focus if we have it
+ let focus = global.stage.get_key_focus();
+ this._content.hide();
+
meta.resultDisplay.renderResults(metas);
- }
+ this._maybeSetInitialSelection();
+
+ this._content.show();
+ if (this._content.contains(focus))
+ global.stage.set_key_focus(focus);
+ }));
}
this._maybeSetInitialSelection();
},
for (let i = 0; i < results.length; i++) {
let [provider, providerResults] = results[i];
let meta = this._metaForProvider(provider);
- meta.hasPendingResults = provider.async;
- if (!meta.hasPendingResults)
- this._updateProviderResults(provider, providerResults, terms);
+ meta.hasPendingResults = true;
}
this._content.show();
_init: function() {
this.parent(_("Your favorite Easter Egg"));
- this.async = true;
},
- getResultMetasAsync: function(fish, callback) {
+ getResultMetas: function(fish, callback) {
callback([{ 'id': fish[0], // there may be many fish in the sea, but
// only one which speaks the truth!
'name': capitalize(fish[0]),
}]);
},
- getInitialResultSetAsync: function(terms) {
+ getInitialResultSet: function(terms) {
if (terms.join(' ') == MAGIC_FISH_KEY) {
this.searchSystem.pushResults(this, [ FISH_NAME ]);
} else {
}
},
- getSubsearchResultSetAsync: function(previousResults, terms) {
- this.getInitialResultSetAsync(terms);
+ getSubsearchResultSet: function(previousResults, terms) {
+ this.getInitialResultSet(terms);
},
activateResult: function(fish, params) {